package com.wesley.test.dao;

import com.wesley.test.entity.User;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

import javax.transaction.Transactional;

public interface UserDao extends JpaRepository<User, Integer> {

    User getByName(String name);

    List<User> findByNameAndSex(String name, String sex);
    
    @Transactional
    @Modifying
    @Query(value = "delete from user where id =?1", nativeQuery = true)
    void deleteByUid(int userId);

}
